1. Field of the Invention
The present invention relates to a memory sharing system, a method thereof, and a medium thereof and, more particularly, to a memory sharing system for sharing a memory between a plurality of computers, a method thereof, and a medium thereof.
2. Description of the Related Art
There is known a technique in which a plurality of virtual machines run on a single real computer. When a plurality of virtual machines run on a single real computer, independent memory areas are assigned to the respective virtual machines, whereby the number of memory areas proportional to the number of the virtual machines are required. Thus, when a plurality of virtual machines run on a small computer, such as an equipment-installed device, having limited hardware resources, a shortage of the memory area may occur.
There may be a case where the same program runs on a plurality of virtual machines running on the single real computer. However, the memory areas that the respective virtual machines use are reserved individually on a memory of the real computer. As a result, the same program file is redundantly loaded into the memory of the real computer. For example, it is assumed here that two Linux-based virtual machines run on the single real computer. In this case, there may be a case where a glibc library file of the same version is loaded into memory areas of the respective virtual machines. In view of this, a memory sharing system has been desired to share a program file loaded in a memory when the same program run on a plurality of virtual machines.
An example of a memory sharing system in an OS (Operating System) is described in a literature (DANIEL P. BOVET et al, “Understanding the Linux Kernel, 2nd Edition”, O'Reilly Japan, 24 Jun. 2003, pp. 580 to 591). The “Understanding the Linux Kernel, 2nd Edition” describes a system in which a plurality of programs can refer to a file loaded in a memory. Although this technique is well known as a memory sharing technique in one OS, it cannot be applied to a memory sharing technique between a plurality of virtual machines. Hereinafter, the reason that this method cannot be applied to a memory sharing technique between a plurality of virtual machines will be described.
In the system described in the above literature, when a program running on the OS refers to a file, it identifies file data to be loaded into a memory based on an identifier (i-node number) assigned to a target file by the OS and an offset value in the file. When a reference request for the same file/same offset as that to which one program is currently referring is made by another program running on the same OS, the OS allows the another program to refer to the file data that has already been loaded into a memory. In this way, the memory sharing between a plurality of programs is performed.
It is assumed that the technique described in the above literature is applied to the memory sharing between a plurality of virtual machines. In this case, the respective virtual machines have different virtual storage units, whereby even if different virtual machines refer to a file having the same i-node number, there is a possibility that the target files differ from one another. For example, in the case where virtual machines A and B refer to a file “/sbin/init”, it is likely that “/sbin/init” in the virtual storage unit of the virtual machine-A and “/sbin/init” in the virtual storage unit of the virtual machine-B differ from each other. Thus, even in the case where the same i-node number is assigned to two files, if a program file sharing is performed by regarding the two files as the same one, a program may fail to run. As described above, the memory sharing system described in the above literature cannot be used as a memory sharing system between a plurality of virtual machines.
An example of the memory sharing system between a plurality of virtual machines is described in Patent Publication JP-11-249916A and Patent Publication JP-2006-252554A. JP-11-249916A describes a system that performs memory area sharing between a plurality of virtual machines running on the single real computer. In this system, a memory is previously divided into some blocks, and a control table specifying “block that can be referred to only by a specific virtual machine” or “block that can be shared between a plurality of virtual machines” is prepared. When one virtual machine runs, a control program for managing memory blocks assigns a given memory block to the virtual machine based on the prepared control table.
JP-2006-252554A describes a system in which a memory area managed by one virtual machine is shared with another virtual machine. In this system, when a virtual machine-A receives a memory access request from a virtual machine-B the virtual machine-A maps a part of the memory area that the virtual machine-A itself manages onto the virtual machine-B which is the access request source. At this stage, the virtual machine-A manages the reference count of a page assigned to the virtual machine-B and can release the mapping when the reference count assumes zero.
A first problem is that when the same program runs on a plurality of virtual machines, a program file loaded into a memory cannot be shared between them. The reason is that although JP-11-249916A and JP-2006-252554A describe a method of sharing a memory area between a plurality of virtual machines, the above method cannot be applied to sharing of a program file between them. A second problem is that when the same program runs on both a virtual machine and a real computer, a program file loaded into a memory cannot be shared between them. The reason is that although the method of JP-11-249916A and JP-2006-252554A can be applied to a method of sharing a memory area between the virtual machine and the real computer, it cannot be applied to sharing of a program file between them.